﻿using NUnit.Framework;
using Pantry.Entity;
using Pantry.DataAccess;
using Pantry.Business;

namespace Pantry.UnitTest
{
    [TestFixture]
    public class TestDirectorateDao
    {
        private Directorate _directorate;
        private Directorate _nullDirectorate;
        private Directorate _invalidDirectorate;
        private DirectorateDao _directorateDao;
        private DirectorateBus _directorateBus;
        private const string ConnectionString = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";

        [SetUp]
        public void Init()
        {
            _directorateDao = new DirectorateDao(ConnectionString);
            _directorateBus = new DirectorateBus();
            _directorate = new Directorate
                {
                    DirectorateId = 1,
                    DirectorateName = "Directorate 1",
                    DirectorateShortDescription = "Directorate 1",
                    OrganizationId = 1,
                    ContactId = 1, //Chua xu ly
                    AddressLine1 = "Addr 1",
                    AddressLine2 = "Addr 1",
                    AddressLine3 = "Addr 1",
                    Postcode = "123",
                    Town = "Ha Noi",
                    County = "Ha Noi",
                    Country = "Vietnam",
                    TypeOfBusinessId = 1,
                    SICcode = "123",
                    DirectorateFullDescription = "Directorate 1",
                    PhoneNumber = "122212",
                    Email = "dir1@mail.com",
                    Fax = "123",
                    WebAddress = "http://web.vn",
                    CharityNumber = "123",
                    CompanyNumber = "123",
                    IsActive = true
                };
            _nullDirectorate = new Directorate();
            _invalidDirectorate = new Directorate
                {
                    DirectorateId = 1,
                    DirectorateName = "Directorate 1",
                    DirectorateShortDescription = "Directorate 1",
                    OrganizationId = 1,
                    ContactId = 1, //Chua xu ly
                    AddressLine1 = "Addr 1",
                    AddressLine2 = "Addr 1",
                    AddressLine3 = "Addr 1",
                    Postcode = "123",
                    Town = "Ha Noi",
                    County = "Ha Noi",
                    Country = "Vietnam",
                    TypeOfBusinessId = 1,
                    SICcode = "123",
                    //DirectorateFullDescription = "Directorate 1",
                    PhoneNumber = "122212",
                    Email = "dir1@mail.com",
                    Fax = "123",
                    WebAddress = "http://web.vn",
                    CharityNumber = "123",
                    CompanyNumber = "123",
                    IsActive = true
                };
        }
        #region Insert method
        [Test]
        public void TestInsertDirectorate_ValitDirectorate_True()
        {
            const bool expected = true;
            var actual = _directorateBus.CreateDirectorate(_directorate);
            Assert.AreEqual(expected, actual);
        }
        [Test]
        public void TestInsertDirectorate_NullDirectorate_False()
        {
            const bool expected = false;
            var actual = _directorateBus.CreateDirectorate(_nullDirectorate);
            Assert.AreEqual(expected, actual);
        }
        [Test]
        public void TestInsertDirectorate_InvalidDirectorate_False()
        {
            const bool expected = false;
            var actual = _directorateBus.CreateDirectorate(_invalidDirectorate);
            Assert.AreEqual(expected, actual);
        }
        #endregion
    }
}
